﻿﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典目录管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {

           $('.btn-input') .click(function() {
               console.log(this);
               //得到的数据就是js对象
               var data = $(this).data('json');
               var $li = $('#systemDictionaries > li.active');
               var id = $li.attr('systemDictionaryId');
               var title = $li.html();
               var $inputParentId = $('#inputParentId > option');
               $inputParentId.val(id);
               $inputParentId.html(title);
               //清除数据
               $('#editForm')[0].reset();
               if(data){
                   //设置值
                   $('input[name="title"]').val(data.title);
                   $('input[name="id"]').val(data.id);
                   $('input[name="sequence"]').val(data.sequence);
                   $('#inputParentId >option').val(data.systemDictionaryId);
                   $('#inputParentId > option').html(data.systemDictionaryTitle)
               }
               //显示模态框
               $('#editModal').modal('show');

           });
         /*  $('.btn-delete').click(function () {
               var id =$(this).data('json');
               $.post('/systemDictionaryItem/delete.do',{id:id},function (data) {
                   if(data.success){
                       $.messager.confirm("温馨提示",data.msg,function () {
                           window.location.reload();
                       });
                   }else{
                        $.messager.alert("温馨提示",data.msg);
                   }
               })
           })*/
           $('.btn-submit').click(function () {
               // 使用 AJAX 异步提交
               $('#editForm').ajaxSubmit(function (data) {
                  // console.log(1);
                   if(data.success){
                        $.messager.confirm('温馨提示',data.msg, function () {
                           //window.location.reload();
                          location.href='/systemDictionaryItem/list.do'
                       });
                    }else{
                        $.messager.alert('温馨提示',data.msg);
                    }
               });
           })
        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#--<c:set var="currentMenu" value="systemDictionaryItem"/>-->
    <#assign currentMenu = "systemDictionaryItem">
    <#--<%@include file="/WEB-INF/views/common/menu.jsp"%>-->
    <#include "../common/menu.ftl">
    <div class="content-wrapper">


        <div class="row">
            <div class="col-md-3"> <section class="content-header">
                <h1>字典目录</h1>
                <ul class="list-group" id="systemDictionaries">
                    <#list systemDictionaries as systemDictionary>
                        <li class="list-group-item system-dictionary <#if qo.parentId?? && qo.parentId == systemDictionary.id>active</#if>" systemDictionaryId="${systemDictionary.id}">
                            ${systemDictionary.title}
                        </li>
                    </#list>
                </ul>
                <script>
                    $(function () {
                        $('.system-dictionary').click(function () {
                            var id = $(this).attr('systemDictionaryId');
                            $('input[name="parentId"]').val(id);
                            $('#searchForm').submit();

                        })
                    })
                </script>
            </section></div>
            <div class="col-md-9"><section class="content">
                <div class="box">
                    <!--高级查询--->
                    <form class="form-inline" id="searchForm" action="#" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <input type="hidden" name="parentId" id="parentId" value="${(qo.parentId)!}">
                    <@shiro.hasPermission name="systemDictionaryItem:saveOrUpdate">
                        <#if qo.parentId??>
                        <a class="btn btn-success btn-input" style="margin: 10px">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>
                        </#if>
                    </@shiro.hasPermission>
                    </form>
                    <!--编写内容-->
                    <div class="box-body table-responsive no-padding ">
                        <table class="table table-hover table-bordered">
                            <tr>
                                <th>编号</th>
                                <th>标题内容</th>
                                <th>标题</th>
                                <th>序列</th>
                                <th>操作</th>
                            </tr>
                        <#list pageInfo.list as systemDictionaryItem >
                            <tr>
                                <td>${systemDictionaryItem_index +1}</td>
                                <td>${systemDictionaryItem.title}</td>
                                <td>${systemDictionaryItem.systemDictionary.title}</td>
                                <td>${systemDictionaryItem.sequence}</td>
                                <td>
                                    <@shiro.hasPermission name="systemDictionaryItem:saveOrUpdate">
                                        <#if qo.parentId??>
                                        <a data-json='${systemDictionaryItem.jsonData}' class="btn btn-info btn-xs btn-input">
                                            <span class="glyphicon glyphicon-pencil"></span> 编辑
                                        </a>
                                        </#if>
                                    </@shiro.hasPermission>
                                    <@shiro.hasPermission name="systemDictionaryItem:delete">
                                        <a data-id='${systemDictionaryItem.id}' data-url='/systemDictionaryItem/delete.do' class="btn btn-danger btn-xs btn-delete">
                                            <span class="glyphicon glyphicon-trash"></span> 删除
                                        </a>
                                    </@shiro.hasPermission>

                                </td>
                            </tr>
                        </#list>

                        </table>
                        <!--分页-->
                    <#include "../common/page.ftl">
                    </div>
                </div>
            </section>
            </div>
        </div>
    </div>
    <#include "../common/footer.ftl">
</div>
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">字典目录编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" value="" name="id">
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">标题</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="inputParentId" name="parentId" readonly>
                                <option value=""></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">标题内容：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" value="" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">序列：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="sequence" value="" >
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary btn-submit">保存</button>
                <button type="button" class="btn btn-danger" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
